from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time
testCase="DBshop014_删除分类"
testName="商品分类测试"
# 1.点击分类名称为“商品分类测试”后方的删除分类"链接
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
time.sleep(1)
DBshopEnterMenu3(firefox,"商品管理","管理分类","商品分类")
time.sleep(2)
firefox.find_element_by_xpath(
    "//td[contains(.,'%s')]/following-sibling::td[4]/a[3]"%testName).click()
time.sleep(2)
firefox.switch_to.alert.accept()
time.sleep(4)
# 断言 页面还能找到“商品分类测试”表示失败，否则就成功。if反过来写。if容易报错所以用try来
try:
    if firefox.find_element_by_xpath("//td[contains(.,'%s')]"%testName).is_displayed():
        writeLog("%s 测试失败" % testCase)
        getPhoto(firefox)
except:
    writeLog("%s 测试通过" % testCase)
    time.sleep(2)
firefox.quit()